 <?php require_once ADMINVIEWPATH.'admin_header.php'; ?>
<?php require_once ADMINVIEWPATH.'admin_menu.php'; ?>
 <link href="<?= STATICURL; ?>css/bootstrap.min.css" rel="stylesheet" />
    <link id="bootstrap-rtl-link" href="" rel="stylesheet" />
    <link href="<?= STATICURL; ?>css/font-awesome.min.css" rel="stylesheet" />
    <link href="<?= STATICURL; ?>css/weather-icons.min.css" rel="stylesheet" />
    <!--Fonts-->
    <!--Beyond styles-->
    <link id="beyond-link" href="<?= STATICURL; ?>css/beyond.min.css" rel="stylesheet" type="text/css" />
    <link href="<?= STATICURL; ?>css/demo.min.css" rel="stylesheet" />
    <link href="<?= STATICURL; ?>css/typicons.min.css" rel="stylesheet" />
    <link href="<?= STATICURL; ?>css/animate.min.css" rel="stylesheet" />
    <link id="skin-link" href="" rel="stylesheet" type="text/css" />
    <div class="page-content">
         <!-- Page Breadcrumb -->
        <div class="page-breadcrumbs">
            <ul class="breadcrumb">
                <li>
                    <i class="fa fa-home"></i>
                    <a href="#">首页</a>
                </li>
                <li class="">
                    <a href="#">新闻</a>
                </li>
            </ul>
        </div>
        <div class="page-body">
            <div >
                <div id="horizontal-form">
                    <form class="form-horizontal" role="form">
                        <div class="row">
                            <div class="col-md-6">
                                <input type="text" name="title" placeholder="标题" class="form-control" value="<?= $NewsInfo['title']?>">
                                <div class="horizontal-space"></div>
                            </div>
                            <div class="col-md-6">
                                <select class="js_newscat">
                                    <option value="0">-----顶级分类----</option>
                                    <?php foreach($news_cat_list as $k=>$v):?>   
                                            <option <?php if($NewsInfo['cat_id'] == $v['cat_id']):?>selected<?php endif;?>   style="font-weight:bold;" value="<?=$v['cat_id']?>">
                                                <?=$v['cat_name']?>
                                            </option>                                                                   
                                    <?php endforeach;?>                                                                 
                                </select>
                            </div>
                        </div>
                        <div style="clear:both"> 
                            <textarea class="form-control contents" rows="3" id="contents" name="contents" placeholder="Content" style="height:500px;width:90%">
                                <?=$NewsInfo['content']?>
                            </textarea>
			            </div>
                        <div>
                            <span id="editNews" class="btn btn-default">提交</span>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <input type="hidden" id="idpalce" value="<?php echo $NewsInfo['newsID']?>" />
<script src="<?= STATICURL; ?>kindeditor/kindeditor.js"></script>
<?php require_once ADMINVIEWPATH.'admin_footer.php'; ?>
<script>
var editor;
KindEditor.ready(function(K) {
    editor = K.create('#contents',{allowFileManager : true});
});
    $(document).ready(function() {
        $("#editNews").click(function(){
             editor.sync();//Js获取值时前面添加
            var contents =editor.html();
            var title = $("input[name='title']").val();
            var cat_id = $(".js_newscat").find("option:selected").val();
            var id = $("#idpalce").val();
            if(contents == ""){
                layer.msg("内容不能为空");return false;
            }
            if(cat_id == ""){
                layer.msg("新闻分类不能为空");return false;   
            }
            if(title == ""){
                layer.msg("标题不能为空");return false;   
            }
	    $.post("<?=BASEURL?>luckydog/news/editNews", {"contents":contents,"title":title,"cat_id":cat_id,"id":id}, function(res) {
                if (res) {
                    layer.msg("成功");
                    window.location.href="/luckydog/news/index";
                }else{
                    layer.msg("失败");
                }
            });
        });
    });
</script>


